Skip to content
This repository was archived by the owner on Dec 25, 2025. It is now read-only.

Fix invalid schema and typos in graphql-config - #54

Merged
IzumiSy merged 9 commits into
mainfrom
fix_graphql-config_exports
Oct 30, 2024
Merged

Fix invalid schema and typos in graphql-config#54
IzumiSy merged 9 commits into
mainfrom
fix_graphql-config_exports

Conversation

@IzumiSy

@IzumiSy IzumiSy commented Oct 28, 2024

Copy link
Copy Markdown
Member

This PR has the following two bugfixes.

Bug 1: types in exports

I came across unexpected behaviour that apps that use @fabrix-framework/graphql-config cannot import anything.

That is caused by typos in packge.json exports made in #32. This PR fixes them.

Bug 2: custom schema definitions go undefined

This is bug caused in #42 which has broken up a custom graphql schema into multiple files, and it accidentally removed a line to call parse function from graphql-js package. GraphQL files are loaded as string, so parsing it into DocumentNode is required. However, I could not notice it at that time due to usage of vite-plugin-graphql-loader in tests that dazzles TypeScript compiler, so on production the GraphQL files that I tried to import gets undefined.

In order to prevent the issue, I removed vite-plugin-graphql-loader and just use vite-plugin-string to make it work as the same condition as tsup does to build for production.

Plus, I added a test that checks if the schema is valid or not with buildASTSchema function from graphql-js.

Leftover: invalid directive definitions

By making CI work as expected, I discovered that constraint feature has several duplicated fields that are not allowed in GraphQL, but fixing that would make more changes in core, so I would like to isolate the topic and limit the changes in this PR just in graphql-config package if possible.

#56 is the issue I have created to work on in another PR, maybe next of this.

@IzumiSy IzumiSy self-assigned this Oct 28, 2024
@IzumiSy
IzumiSy requested a review from a team as a code owner October 28, 2024 07:35
@pkg-pr-new

pkg-pr-new Bot commented Oct 28, 2024

Copy link
Copy Markdown

Open in Stackblitz

pnpm add https://pkg.pr.new/fabrix-framework/fabrix/@fabrix-framework/chakra-ui@54
pnpm add https://pkg.pr.new/fabrix-framework/fabrix/@fabrix-framework/fabrix@54
pnpm add https://pkg.pr.new/fabrix-framework/fabrix/@fabrix-framework/graphql-config@54

commit: 90d8382

@IzumiSy IzumiSy changed the title Fix typo in package.json exports in graphq-config Fix invalid schema extraction and typos in exports in graphql-config Oct 28, 2024
@IzumiSy
IzumiSy force-pushed the fix_graphql-config_exports branch from fdfe10d to a616d99 Compare October 28, 2024 09:16
Comment on lines -7 to -10
const mergeDocumentNodes = (docs: DocumentNode[]) => ({
kind: Kind.DOCUMENT,
definitions: docs.flatMap((doc) => doc.definitions),
});

@IzumiSy IzumiSy Oct 28, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found that merging like this is not working as expected, so now here is using use @graphql-tools/merge instead.

@IzumiSy
IzumiSy force-pushed the fix_graphql-config_exports branch from a883c4d to 90af572 Compare October 28, 2024 09:49
@IzumiSy
IzumiSy marked this pull request as draft October 28, 2024 10:03
@IzumiSy IzumiSy changed the title Fix invalid schema extraction and typos in exports in graphql-config Fix invalid schema and typos in graphql-config Oct 28, 2024
import { buildASTSchema } from "graphql";
import { schemaDefinition } from "./schema";

describe.skip("schemaDefinition", () => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to remove skip here when I work on #56.

@IzumiSy
IzumiSy marked this pull request as ready for review October 29, 2024 10:15

@murayama-r murayama-r left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@IzumiSy
IzumiSy merged commit 8092179 into main Oct 30, 2024
@IzumiSy
IzumiSy deleted the fix_graphql-config_exports branch October 30, 2024 00:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants